import { EntityUtil } from "../../../scene/layer/utils/EntityUtil";
import { Language } from "../../../../../extend/language/Language";
import { SCrossMassacreServerKey } from "../../../../../Message/Public/SCrossMassacreServerKey";
import { CrossMassacreCache } from "../../../cache/CrossMassacreCache";
import { GameConst } from "../../../../component/gconst/GameConst";
type int = number;
//class CrossMassacreServerData
    
    export  class CrossMassacreServerData
    {
        

        public get mouseEnabled(): Boolean
        {
            return this._mouseEnabled;
        }

        public set mouseEnabled(arg1: Boolean)
        {
            this._mouseEnabled = arg1;
            return;
        }

        public get loseWinPercentage(): int
        {
            return this._loseWinPercentage;
        }

        public set loseWinPercentage(arg1: int)
        {
            this._loseWinPercentage = arg1;
            return;
        }

        public toString(): string
        {
            var loc1="";
            if (this.info == null) 
            {
                return loc1;
            }
            loc1 = "[" + EntityUtil.getProxyNameByProxyAndServer(this.info.serverKey.proxyId, this.info.serverKey.serverId, "-") + "]";
            loc1 = loc1 + Language.getStringByParam(80497, this.info.money.toString(), this.chooseNum.toString());
            return loc1;
        }

        public get chooseNum(): int
        {
            if (this.chooseList == null) 
            {
                return 0;
            }
            return this.chooseList.length;
        }

        public get countryMoney(): int
        {
            if (this.info == null) 
            {
                return 0;
            }
            return this.info.money;
        }

        public get serverName(): string
        {
            if (this.info == null) 
            {
                return Language.getString(80508);
            }
            if (EntityUtil.isSameServerByProxyAndServer(this.info.serverKey.proxyId, this.info.serverKey.serverId)) 
            {
                return Language.getString(80500);
            }
            return EntityUtil.getProxyNameByProxyAndServer(this.info.serverKey.proxyId, this.info.serverKey.serverId, "-");
        }

        public getMassacreServerNames(arg1: string="  "): string
        {
            var loc6=null;
            var loc1="";
            var loc2=Language.getString(80508);
            var loc3=[loc2, loc2, loc2];
            if (this.chooseList == null) 
            {
                return this.translateArr2Str(loc3, arg1);
            }
            var loc4=0;
            var loc5=0;
            while (loc5 < this.chooseList.length) 
            {
                if (!((loc6 = this.chooseList[loc5] as SCrossMassacreServerKey) == null || loc6.serverKey == null)) 
                {
                    if (EntityUtil.isSameServerByProxyAndServer(loc6.serverKey.proxyId, loc6.serverKey.serverId)) 
                    {
                        loc1 = Language.getString(80500);
                    }
                    else 
                    {
                        loc1 = EntityUtil.getProxyNameByProxyAndServer(loc6.serverKey.proxyId, loc6.serverKey.serverId, "-");
                    }
                    var loc7;
                    loc3[loc7 = loc4++] = loc1;
                }
                ++loc5;
            }
            return this.translateArr2Str(loc3, arg1);
        }

        /* internal  */translateArr2Str(arg1: Array<any>, arg2: string): string
        {
            var loc1="";
            var loc2=0;
            while (loc2 < arg1.length) 
            {
                loc1 = loc1 + arg1[loc2];
                if (loc2 < (arg1.length - 1)) 
                {
                    loc1 = loc1 + arg2;
                }
                ++loc2;
            }
            return loc1;
        }

        public get selected(): Boolean
        {
            if (this.chooseList == null) 
            {
                return false;
            }
            return CrossMassacreCache.isOurServerInList(this.chooseList);
        }

        public get enabled(): Boolean
        {
            if (this.chooseList == null) 
            {
                return true;
            }
            return this.chooseList.length < GameConst.CrossMassacreBeChooseMaxNum;
        }

        public /* var */info: SCrossMassacreServerKey;

        public /* var */chooseList: Array<any>;

        /* internal */ /* var */_loseWinPercentage: int=15;

        /* internal */ /* var */_mouseEnabled: Boolean=true;
    }
